<template>
  <div class="entry-wrap">
    <div class="bg-box"></div>

    <div class="wrap-box">
      <div class="imgbox"><img src="./lend.png" class="logo" onclick="return false"/></div>
      <div class="subbox" @click="lendPage">蓝聘借支<img src="../../../images/in.png" class="arrow" onclick="return false"/>
      </div>
    </div>
    <div class="wrap-box">
      <div class="imgbox"><img src="./interview.png" class="logo" onclick="return false"/></div>
      <div class="subbox" @click="interviewPage">面试预约<img src="../../../images/in.png" class="arrow"
                                                          onclick="return false"/></div>
    </div>
    <div class="wrap-box">
      <div class="imgbox"><img src="./leave.png" class="logo" onclick="return false"/></div>
      <div class="subbox" @click="leavePage">离职通知<img src="../../../images/in.png" class="arrow"
                                                      onclick="return false"/></div>
    </div>
    <div class="wrap-box">
      <div class="imgbox"><img src="./rating.png" class="logo" onclick="return false"/></div>
      <div class="subbox" @click="ratePage">企业点评<img src="../../../images/in.png" class="arrow" onclick="return false"/>
      </div>
    </div>

    <v-alert content="您尚未入职，暂不支持离职通知！" v-model="modal"></v-alert>
    <v-dialog v-model="sendVal" :content="content" cancelText="取消" confirmText="去绑定" @confirm="bindPage"
              @cancel="cancel"></v-dialog>
  </div>
</template>

<script>
  import {baseUrl} from "../../../common/js/env"
  import {getSessionStore} from "../../../common/js/util"
  import alert from "../../../components/dialog/alert"
  import dialog from '../../../components/dialog/dialog'

  export default {
    data() {
      return {
        userSign: "",
        modal: false,
        sendVal: false,
        content: "您还未绑定工资卡，请先绑定再借支",
      }
    },
    mounted() {
      let base64 = require('js-base64').Base64;
      this.userSign = base64.decode(getSessionStore("user_sign"));
    },
    methods: {
      cancel() {
        this.sendVal = false;
      },
      bindPage() {
        this.sendVal = false;
        sessionStorage.setItem("entry_sgin", "001111");
        this.$router.push("/bindcard");
      },
      lendPage() {//借支
        this.axios.get(baseUrl + "/billrecord/query_bankcardwithDraw?sgin=" + this.userSign).then((res) => {
          let resultObj = res.data;
          if (resultObj.code == 0 && resultObj.data != null) {
            if (resultObj.data.type == 1) { //没有绑定银行卡
              this.sendVal = true;
            } else {
              this.axios.get(baseUrl + "/lendmoney/query_checkrecord?sgin=" + this.userSign).then((res) => {//查询是否有借支记录
                let resultObj = res.data;
                if (resultObj.code == 0 && resultObj.data != null) {
                  this.$router.push("/lendDetail");
                } else {
                  this.$router.push("/lend");
                }
              });
            }
          } else {
            this.$vux.toast.text(resultObj.msg, "middle");
          }
        }).catch(() => {
          this.$vux.toast.text("网络异常", "middle");
        });
      },
      interviewPage() {//面试预约
        this.$router.push("/interview");
      },
      leavePage() {//离职通知
        //获取个人资料
        this.axios.get(baseUrl + "/userMaterial/select?sgin=" + this.userSign).then((res) => {
          let resultObj = res.data;
          if (resultObj.code == 0 && resultObj.data != null) {
            if (resultObj.data.workStatus != 1) {//待业或入职中
              this.modal = true;
            } else {
              this.$router.push('/dimission');
            }
          } else {
            this.$vux.toast.text(resultObj.msg);
            return;
          }
        });
      },
      ratePage() {//企业点评
        this.$router.push({path: "/company", query: {"city": "全国"}});
      }
    },
    components: {
      "v-alert": alert,
      "v-dialog": dialog
    }
  }
</script>

<style lang="stylus" scoped>
  @import "../../../common/stylus/mixin.styl"

  .entry-wrap
    wh(100%, 100%)
    overflow: hidden
    .bg-box
      wh(100%, 3.6rem)
      bg-image("./bg.png", 100%, 100%)
      margin-bottom: 0.28rem
    .wrap-box
      display: flex
      wh(100%, 1.28rem)
      margin-left: auto
      border-bottom: 0.027rem solid #f2f2f2
      .imgbox
        fj(center, center)
        wh(14.27%, 1.28rem)
        .logo
          wh(0.867rem, 0.867rem)
      .subbox
        display: flex
        align-items: center
        wh(85.73%, 1.28rem)
        size-color(0.427rem, rgba(51, 51, 51, 1))
        .arrow
          margin-left: auto
          padding-right: 0.28rem
          wh(0.32rem, 0.32rem)
</style>
